# 求1-100的和
i = 1
sum = 0
while i <= 100:
    
    sum =sum + i
    i = i + 1
print(sum)

# 用while实现猜数字游戏
import random
num = random.randint(1, 100)
mark = True
count = 0
while mark:
    gress_num = int(input("请输入你猜的数字"))
    count += 1
    if gress_num == num:
        print("恭喜你猜对了")
        mark = False
    else:
        if gress_num > num:
            print("你猜的数字大了")
        else :
            print("你猜的数字小了")
print(f"你总共猜了{count}")

